i = input("请输入测试字符串：")
a = []
b = []
c = []
aa = ['{','[','(']
bb = ['}',']',')']
aa.count(')')

a.extend(i)

for x in range(0,len(i)):
    print(a[x])
    print("{"or"["or"(")
    print(a[x] == "{"or"["or"(")
    if aa.count(a[x]) != '':
        b.append(a[x])
        print(b)
        x += 1
    elif bb.count(a[x]) != -1:
        c.append(a[x])
        print(c)
        x += 1
c.reverse()
print(c)
print(b)
print(len(b))
print(len(c))
print(len(b) == len(c))
if (len(b) == len(c)):
    hefa = True
    for n in range(0,len(b)):
        if b[n] == "{" and c[n] == "}":
            print(b[n])
            n += 1
        elif b[n] == "(" and c[n] == ")":
            print(b[n])
            n += 1
        elif b[n] == "[" and c[n] == "]":
            print(b[n])
            n += 1
        else:
            hefa = False
            break
    if hefa == True:
        print("合法^o^")
    else:
        print("非法T_T")
else:
    print("非法T_T")

